<template>
  <div class="rights">
    <!-- 导航面包屑 -->
    <bread :linktitle="link"></bread>
    <!-- 导航面包屑 -->

    <!-- 权限列表 -->
    <div class="right_wrap" v-if="tableData.length">
      <el-table :data="tableData" border height="565" style="width: 100%">
        <el-table-column type="index" label="#" width="50"></el-table-column>
        <el-table-column prop="authName" label="权限名称"> </el-table-column>
        <el-table-column prop="path" label="路径"> </el-table-column>

        <el-table-column prop="level" label="权限等级 ">
          <template slot-scope="scope">
           <!-- <el-tag :type="scope.row.level | tyright">{{ scope.row.level | flright}}</el-tag> -->
        <el-tag type="success" v-if="scope.row.level == '0'">一级</el-tag>
         <el-tag type="info" v-else-if="scope.row.level == '1'">二级</el-tag>
         <el-tag type="warning" v-else>三级</el-tag>
          </template>
        </el-table-column>
      </el-table>
    </div>
    <!-- 权限列表 -->
  </div>
</template>
<script>
import bread from "../../common/breadcrumb";
export default {
  name: "rights",
  data() {
    return {
      link: ["权限管理", "权限列表"],
      tableData: [
        {
        
        },
      ],
    };
  },
  components: {
    bread,
  },
  created() {
    this.getright();
  },
  methods: {
    async getright() {
      let data = await this.$http.get("rights/list");
      if (data.meta.status !== 200) return this.$message.error("获取失败");
      this.tableData = data.data;
    },
  },
  filters: {
    flright(value) {
      switch (value) {
        case "0":
          return "0级";
          break;
        case "1":
          return "1级";
          break;
        case "2":
          return "2级";
          break;
        default:
          return value;
          break;
      }
    },
    tyright(value){
 switch (value) {
        case "0":
          return "success";
          break;
        case "1":
          return "info";
          break;
        case "2":
          return "warning";
          break;
        default:
          return "danger";
          break;
      }
    }
  },
};
</script>
<style scoped lang="less">
.right_wrap {
  margin-top: 20px;
  padding: 20px;
  box-sizing: border-box;
  background-color: #fff;
}
</style>